package com.admin.dbdao;

import com.client.bean.FeedBack;
import com.data.dbdao.BaseDao;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.List;

/**
 * 统计管理
 *
 * @author:HingLo
 * @create 2017-10-13 15:17
 **/
@Repository
@Transactional
public class StatisticsAdminDao extends BaseDao {
    private static Logger logger = Logger.getLogger(StatisticsAdminDao.class);

    public List<FeedBack> findFeedbackDao() {
        String hql = "from FeedBack";
        return (List<FeedBack>) super.findMassageDao(hql);
    }

    public List<?> findReportDao() {
        String hql = "select r.id,r.uid,a.name,r.type,r.content,r.ctime,r.state from Report as r ,App as a where r.rid=a.id";
        return super.findMassageDao(hql);
    }

    /**
     * 修改反馈信息的阅读状态
     *
     * @param id
     * @return
     */
    public boolean updateFeedbackInfoStateDao(String id) {
        String hql = "update FeedBack set state=? where id=?";
        return super.updateOneMssageDao(hql, true, id);
    }

    /**
     * 删除反馈信息的阅读状态
     *
     * @param id
     * @return
     */
    public boolean deleteFeedbackInfoStateDao(String id) {
        String hql = "delete FeedBack  where id=?";
        return super.updateOneMssageDao(hql, id);
    }

    /**
     * 标记举报软件的状态
     *
     * @param id
     * @return
     */
    public boolean updateReportInfoStateDao(String id) {
        String hql = "update Report set state=? where id=?";
        return super.updateOneMssageDao(hql, true, id);
    }

    /**
     * 删除举报信息
     *
     * @param id
     * @return
     */
    public boolean deleteReportInfoStateDao(String id) {
        String hql = "delete Report  where id=?";
        return super.updateOneMssageDao(hql, id);
    }


}
